<?php
class Add_user extends CI_Controller{
    
    public function __construct(){
        parent::__construct();
        $this->load->library('form_validation');
        $this->load->model('user_model');
    }
    public function create(){
       $this->form_validation->set_rules(
            array(
                array(
                    'field' => 'username', 
                    'label' => 'username', 
                    'rules' => 'trim|required'
                    ),
                array('field' => 'user_email', 'label' => 'Email', 'rules' => 'trim|required|valid_email|callback_email_check'),
                array(
                    'field' => 'user_password', 
                    'label' => 'user_password', 
                    'rules' => 'trim|required'
                    )
               ));
              
       if ($this->form_validation->run() == FALSE)	 {
           $p=base_url().'add_user';
           echo $p; die;
           redirect($p);
               	 
		}else  
        {
            $input_data['user_name']=$this->input->post('username')  ;
            $input_data['doj']=$this->input->post('doj')  ;
            $input_data['dob']=$this->input->post('dob')  ;
            $this->user_model->create($input_data);
        } 
         
    }
    
} 
?>